package org.ly817.busCode.core;

import java.io.*;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * @author LuoYu
 * @date 2019/02/26 16:45
 * <p>
 * Description:
 * s
 */
public class SQLMaker {

    public static String timeStampFactory() {

        return null;

    }

    public static void main(String[] args) throws IOException {
        LocalDateTime now = LocalDateTime.of(2019, 2, 26, 20, 0, 0);
        LocalDateTime end = LocalDateTime.of(2019, 1, 26, 20, 0, 0);
        Long id = 1000L;
        File file = new File("auto.sql");
        OutputStream outputStream = new FileOutputStream(file);

        while (end.isBefore(now)) {
            now = now.minusMinutes(5);
            id = id + 1;
            Table t = new Table();
            t.setSecondWaterId(id);
            t.setElectricCurrentA(1L);
            t.setElectricCurrentB(1L);
            t.setElectricCurrentC(1L);
            t.setVoltageA(1L);
            t.setVoltageB(1L);
            t.setVoltageC(1L);
            t.setElecSum(1L);
            t.setStsDate(now.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
            outputStream.write(t.getInsertSql().getBytes());
//            System.out.println(t.getInsertSql());

        }
        outputStream.flush();
        outputStream.close();
    }
}
